# coding: utf-8
import requests
import threading
from requests.exceptions import RequestException

url = "http://localhost:9000/todo/api/v1.0/item/1"
faild_num = 0

def request(i):
	global faild_num
	url = "http://localhost:9000/todo/api/v1.0/item/%s" % i
	try:
		resp = requests.get(url)
		print(i, resp.status_code, '\n')
	except RequestException as e:
		print(i, e, '\n')
		faild_num += 1

def request2(i):
	global faild_num
	url = "http://localhost:5010/get/"
	try:
		resp = requests.get(url)
		print(i, resp.text, resp.status_code, '\n')
	except RequestException as e:
		print(i, e, '\n')
		faild_num += 1


ts = []
for i in range(10):
	# t = threading.Thread(target=request, args=(i,))
	t = threading.Thread(target=request2, args=(i,))
	t.setDaemon(True)
	ts.append(t)

for t in ts:
	t.start()

for t in ts:
	t.join()

print(faild_num)